package cn.aezo.minions.gen.mapper;

import cn.aezo.minions.gen.model.Template;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * Created by smalle on 2017/10/21.
 */
public interface TemplateDao extends BaseMapper<Template> {
    @Select("select * from template where user_id = #{userId} and valid_status = 1")
    List<Map<String, Object>> findTemplateByUserId(Long userId);

    @Select("select cast(template_item_id as char) as \"id\", template_item_id as \"templateItemId\", " +
            " cast(pid as char) as \"pid\", item_type as \"itemType\", item_name as \"title\", item_name as \"itemName\"," +
            " true as \"spread\", cast(item_value as char) as \"itemValue\"" +
            " from template_item where template_id = #{templateId} and valid_status = 1" +
            " order by item_type, item_name")
    List<Map<String, Object>> findTemplateItemList(Long templateId);
}
